package com.itheima.utils;

import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * @author huyoufu <https://github.com/huyoufu>
 * @TIME 2020-08-05 14:21
 * @description 不是静态的工具类 它也是一个对象!!!!
 */
public class SqlSessionFactoryX {

    public  SqlSessionFactory getSessionFactory(){
        //创建 sqlSessionFactoryBuilder
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();

        InputStream inputStream = SqlSessionFactoryUtil.class.getClassLoader().getResourceAsStream("SqlMapConfig.xml");

        //使用build创建sqlSessionFactory
        SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(inputStream);

        return sqlSessionFactory;
    }

}
